/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nxlv2.nomad.businessobjects;

/**
 *
 * @author Xavier
 */
public enum EtatCommande {

    ENCOURS("en cours","en cours"),
    PARTIELLE("partielle","partielle"),
    COMPLETE("complete","complète"),
   // 'envoyée','en cours','partielle','complète','expediée','annulée','préparée'
    ENVOYEE("envoyee","envoyée"),
    EXPEDIEE("expediee","expediée"),
    ANNULEE("annulee","annulée"),
    PREPAREE("preparee","préparée");
    
    
    
    private final String libelle;
    private final String libWeb;

    /**
     *
     * @param libelle
     */
    EtatCommande(String libelle, String libWeb) {
        this.libelle = libelle;
        this.libWeb = libWeb;
    }

    public static EtatCommande getByLibelle(String lib) {
        for (EtatCommande etat : EtatCommande.values()) {
            if (etat.getLibelle().equals(lib)) {
                return etat;
            }
        }        
        return null; // throw exception ?
    }
    public static EtatCommande getByLibWeb(String lib) {
        for (EtatCommande etat : EtatCommande.values()) {
            if (etat.getLibWeb().equals(lib)) {
                return etat;
            }
        }        
        return null; // throw exception ?
    }

    /**
     *
     * @return libelle
     */
    public String getLibelle() {
        return this.libelle;
    }
    public String getLibWeb() {
        return this.libWeb;
    }

    /**
     *
     * @return String
     */
    @Override
    public String toString() {
        return "EtatCommande{" + "libelle=" + libelle + '}';
    }
    
    public String toJSONString(){
        return "{\"libelle\":\""+ libWeb +"\"}";
    }

}
